<?php

namespace app\admin\model\buy;

use think\Model;


class House extends Model
{

    

    

    // 表名
    protected $name = 'buy_house';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'sex_data_text',
        'position_data_text',
        'architectural_style_data_text',
        'architectural_form_data_text',
        'gardens_data_text',
        'garage_num_data_text',
        'real_estate_cycle_data_text',
        'pay_method_data_text',
        'visiting_route_data_text',
        'purchase_demand_data_text',
        'update_time_text',
        'create_time_text'
    ];
    

    
    public function getSexDataList()
    {
        return ['male' => __('Sex_data male'), 'female' => __('Sex_data female')];
    }

    public function getPositionDataList()
    {
        return ['new_area' => __('Position_data new_area'), 'old_area' => __('Position_data old_area'), 'new_and_old' => __('Position_data new_and_old')];
    }

    public function getArchitecturalStyleDataList()
    {
        return ['like' => __('Architectural_style_data like'), 'commonly' => __('Architectural_style_data commonly'), 'dislike' => __('Architectural_style_data dislike')];
    }

    public function getArchitecturalFormDataList()
    {
        return ['high_level' => __('Architectural_form_data high_level'), 'multi_storey' => __('Architectural_form_data multi_storey'), 'villa' => __('Architectural_form_data villa')];
    }

    public function getGardensDataList()
    {
        return ['like' => __('Gardens_data like'), 'commonly' => __('Gardens_data commonly'), 'dislike' => __('Gardens_data dislike')];
    }

    public function getGarageNumDataList()
    {
        return ['garage' => __('Garage_num_data garage'), 'not_garage' => __('Garage_num_data not_garage')];
    }

    public function getRealEstateCycleDataList()
    {
        return ['1' => __('Real_estate_cycle_data 1'), '3' => __('Real_estate_cycle_data 3'), '6' => __('Real_estate_cycle_data 6'), '12' => __('Real_estate_cycle_data 12')];
    }

    public function getPayMethodDataList()
    {
        return ['1' => __('Pay_method_data 1'), '2' => __('Pay_method_data 2'), '3' => __('Pay_method_data 3'), '4' => __('Pay_method_data 4'), '5' => __('Pay_method_data 5')];
    }

    public function getVisitingRouteDataList()
    {
        return ['1' => __('Visiting_route_data 1'), '2' => __('Visiting_route_data 2'), '3' => __('Visiting_route_data 3'), '4' => __('Visiting_route_data 4'), '5' => __('Visiting_route_data 5'), '6' => __('Visiting_route_data 6'), '7' => __('Visiting_route_data 7'), '8' => __('Visiting_route_data 8'), '9' => __('Visiting_route_data 9'), '10' => __('Visiting_route_data 10'), '11' => __('Visiting_route_data 11')];
    }

    public function getPurchaseDemandDataList()
    {
        return ['1' => __('Purchase_demand_data 1'), '2' => __('Purchase_demand_data 2'), '3' => __('Purchase_demand_data 3'), '4' => __('Purchase_demand_data 4'), '5' => __('Purchase_demand_data 5')];
    }


    public function getSexDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex_data']) ? $data['sex_data'] : '');
        $list = $this->getSexDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPositionDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['position_data']) ? $data['position_data'] : '');
        $list = $this->getPositionDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getArchitecturalStyleDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['architectural_style_data']) ? $data['architectural_style_data'] : '');
        $list = $this->getArchitecturalStyleDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getArchitecturalFormDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['architectural_form_data']) ? $data['architectural_form_data'] : '');
        $list = $this->getArchitecturalFormDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGardensDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gardens_data']) ? $data['gardens_data'] : '');
        $list = $this->getGardensDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGarageNumDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['garage_num_data']) ? $data['garage_num_data'] : '');
        $list = $this->getGarageNumDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRealEstateCycleDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['real_estate_cycle_data']) ? $data['real_estate_cycle_data'] : '');
        $list = $this->getRealEstateCycleDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPayMethodDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_method_data']) ? $data['pay_method_data'] : '');
        $list = $this->getPayMethodDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getVisitingRouteDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['visiting_route_data']) ? $data['visiting_route_data'] : '');
        $list = $this->getVisitingRouteDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPurchaseDemandDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['purchase_demand_data']) ? $data['purchase_demand_data'] : '');
        $list = $this->getPurchaseDemandDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
